﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>新增任务</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
    <link href="../Frozenui1.3/css/frozen.css" rel="stylesheet" />
    <script src="../JS/layer/layer.m.js"></script>
    <script src="../JS/zepto.min.js"></script>
    <script src="../Frozenui1.3/js/frozen.js"></script>
    <script src="http://cdnjs.gtimg.com/cdnjs/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="../JS/Date/FT_Date.min.js"></script>
    <script src="../JS/zepto.min.js"></script>
    <script src="../JS/avalon.min.js"></script>
    <link href="../JS/Date/FT_Date.min.css" rel="stylesheet" />
    <script>
        var height = 0;
        var width = 0;
        var jq = $.noConflict();
        jq(function () {
            var currYear = (new Date()).getFullYear();
            var opt = {
                date: { preset: 'date' },
                defaultopi: {
                    theme: 'android-ics light', //皮肤样式
                    display: 'modal', //显示方式
                    mode: 'scroller', //日期选择模式
                    lang: 'zh',
                    startYear: currYear - 5, //开始年份
                    endYear: currYear + 5, //结束年份
                    onSelect: function (valueText, inst) {
                        //model.ctData.HDTime = valueText;
                    }
                }
            };
            jq("#hdsj").scroller(jq.extend(opt['date'], opt['defaultopi'])).scroller('setDate', new Date(), true);
            model.ctData.RWJZDate = jq("#hdsj").val();
        })

        var model = avalon.define({
            $id: "hdmodel",
            ctData: { "LeiBie": "一般", "RWTitle": "", "RWJZDate": "", "RWFZR": "", "RWCYR": "", "Files": "", "RWStatus": "0" },
            savedata: function () {
                var lg = $.loading({
                    content: '保存中...',
                })
                $.post("/API/WXAPI.ashx?Action=ADDRCTX&r=" + Math.random(), { "P1": JSON.stringify(model.ctData.$model) }, function (data) {
                    lg.hide();
                    var data = $.parseJSON(data);
                    if (data.ErrorMsg == "") {
                        $(".ui-footer").hide();
                        var el = $.tips({
                            content: "保存成功！",
                            stayTime: 2000,
                            type: "success"
                        })
                        el.on("tips:hide", function () {
                            window.location.reload();
                        })
                    }
                    else {
                        $.tips({
                            content: "保存失败，原因：" + data.ErrorMsg,
                            stayTime: 2000,
                            type: "warn"
                        })
                    }
                })
            },
            repshow: function () {
                $(this).parent().siblings().removeClass("active");
                $(this).parent().addClass("active");
            },
            selperson: function () {
                fzcy = $(this);
                $("#content").hide();
                if (fzcy.attr("id") == "rw_fzry") {
                    $("#iframef").show();

                    var cheight = height;
                    var cwidth = document.documentElement.clientWidth - 5;

                    $("#iframef").css("height", cheight);
                    $("#iframef").css("width", cwidth);
                }
                else {
                    $("#iframec").show();

                    var cheight = height;
                    var cwidth = document.documentElement.clientWidth - 5;

                    $("#iframec").css("height", cheight);
                    $("#iframec").css("width", cwidth);
                }

            },
            bjk: function () {

                var tc = layer.open({
                    type: 1,
                    //content:$("#bmxx").html(),
                    //title: "活动简介",
                    content: '<div class="ui-form-item ui-form-item-textarea ui-border-b" style="width:' + (width - 76) + 'px;height:200px"><textarea id="hdjjbjk" style="padding-left: 0;height:170px;border: 1px solid #e0e0e0;" placeholder="请输入任务内容">' + model.ctData.RWTitle + '</textarea></div>',
                    btn: ['确认', '取消'],
                    shadeClose: false,
                    yes: function () {
                        model.ctData.RWTitle = $("#hdjjbjk").val();
                        if ($("#hdjjbjk").val() != "") {
                            $("#hdjj").removeClass("ui-txt-muted");
                            $("#hdjj").html($("#hdjjbjk").val());
                        }
                        else {
                            $("#hdjj").addClass("ui-txt-muted");
                            $("#hdjj").html("请输入任务内容");
                        }

                        layer.close(tc);

                    }, no: function () {
                    }
                })
            }

        });
        var fzcy = "";
        function goback() {
            $("#content").show();
            $("#iframef").hide();
            $("#iframec").hide();
        }
        function goconfirm(json) {
            if (json != null) {
                fzcy.removeClass("ui-txt-muted");
                fzcy.html(json.vuser);
                if (fzcy.attr("id") == "rw_fzry") {
                    model.ctData.RWFZR = json.vusername;
                }
                else {
                    model.ctData.RWCYR = json.vusername;
                }
            }
            else {
                fzcy.addClass("ui-txt-muted");
                if (fzcy.attr("id") == "rw_fzry") {
                    fzcy.html('请输入负责人');
                    model.ctData.RWFZR = '';
                }
                else {
                    fzcy.html('请输入参与人');
                    model.ctData.RWCYR = '';
                }
            }

            $("#content").show();
            $("#iframef").hide();
            $("#iframec").hide();
        }

        avalon.ready(function () {
            width = document.documentElement.clientWidth;
            height = document.documentElement.clientHeight - 11;
            $("#iframef").attr("src", "UI_PERSON.html?r=" + Math.random());
            $("#iframec").attr("src", "UI_PERSON.html?r=" + Math.random());
        })
    </script>
    <style type="text/css">
        .ui-select {
            border: none;
            border: 0;
            background-color: #fff;
            appearance: none;
            -moz-appearance: none; /* Firefox */
            -webkit-appearance: none; /* Safari 和 Chrome */
        }
    </style>
</head>
<body ms-controller="hdmodel">
    <div id="content">
        <div class="ui-footer ui-footer-stable ui-btn-group ui-border-t">
            <button class="ui-btn-lg ui-btn-primary" ms-click="savedata()">
                新增任务
            </button>
        </div>

        <section class="ui-container">
            <div class="ui-form ui-border-t">
                <div class="ui-form-item ui-border-b">
                    <label>
                        任务类型
                    </label>
                    <div class="ui-select ui-border-b">
                        <select ms-duplex="ctData.LeiBie">
                            <option value="一般">一般</option>
                            <option value="重要">重要</option>
                        </select>
                    </div>
                </div>
                <div class="ui-form-item ui-border-b" style="height:auto;min-height:44px">
                    <label>
                        任务内容
                    </label>
                    <div class="ui-txt-muted ui-whitespace" style="padding-left: 95px;text-align:justify" id="hdjj" ms-click="bjk()">请输入任务内容</div>
                    <!--<input type="text" placeholder="请输入任务内容" ms-duplex="ctData.RWTitle" />-->
                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        截止时间
                    </label>
                    <div class="ui-select ui-border-b">
                        <input type="text" placeholder="请输入截止时间" ms-duplex="ctData.RWJZDate" id="hdsj" style="padding-left:0" />

                    </div>
                </div>
                <div class="ui-form-item ui-border-b" style="height:auto">
                    <label>
                        负责人
                    </label>
                    <div class="ui-txt-muted ui-whitespace" style="padding-left: 95px;text-align:justify" id="rw_fzry" ms-click="selperson()">请选择负责人</div>

                </div>
                <div class="ui-form-item ui-border-b" style="height:auto">
                    <label>
                        参与人
                    </label>
                    <div class="ui-txt-muted ui-whitespace" style="padding-left: 95px;text-align:justify" id="rw_cyry" ms-click="selperson()">请选择参与人</div>
                </div>
                <div class="ui-form-item ui-border-b">
                    <label>
                        图片
                    </label>
                </div>
                <div class="ui-form-item ui-form-item-textarea ui-border-b">
                    <a class="ui-icon-add"></a>
                </div>

            </div>
        </section>
    </div>


    <iframe id="iframef" src="UI_PERSON.html" style="display:none"></iframe>
    <iframe id="iframec" src="UI_PERSON.html" style="display:none"></iframe>
</body>
</html>
